import { HTMLAttributes, createElement, type FC } from 'react';
import classNames from 'classnames';

import { flagDefaultProps } from './defaultProps';
import type { FlagOptions } from './type';

export interface FlagProps extends FlagOptions, HTMLAttributes<HTMLElement> {}

const Flag: FC<FlagProps> = (props) => {
  const { className, name, size, forwardedRef, ...flagProps } = props;

  return createElement('i', { ref: forwardedRef, className: classNames(size, name, 'flag', className), ...flagProps });
};

Flag.displayName = 'Flag';
Flag.defaultProps = flagDefaultProps;

export default Flag;
